﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Net;

namespace PFAGame.NetworkingGame
{
    class MobNet
    {
        #region Fields

        public int Id
        {
            get;
            private set;
        }

        public Vector2 Position
        {
            get;
            private set;
        }

        public Vector2 Orientation
        {
            get;
            private set;
        }

        public AMob.e_typeMob Type
        {
            get;
            private set;
        }

        public AMob.e_state State
        {
            get;
            private set;
        }
        
        #endregion

        public MobNet(PacketReader packetReader)
        {
            if (packetReader == null)
                throw new ArgumentNullException("packetReader");

            this.Id = packetReader.ReadInt32();
            this.Type = (AMob.e_typeMob) packetReader.ReadInt32();
            this.State = (AMob.e_state) packetReader.ReadInt32();
            this.Position = packetReader.ReadVector2();
            this.Orientation = packetReader.ReadVector2();
        }

        internal static void Serialize(AMob mob, PacketWriter packetWriter)
        {
            if (packetWriter == null)
                throw new ArgumentNullException("packetWriter");

            packetWriter.Write(mob.Id);
            packetWriter.Write((int) mob.type);
            packetWriter.Write((int) mob.state);
            packetWriter.Write(mob.Position);
            packetWriter.Write(mob.Orientation);
        }
    }
}
